#!/usr/bin/ruby
# -*- ruby -*-
#
# http://programmingpraxis.com/2014/02/18/two-interview-questions/

def solve(n)
  (1).upto(9) do |i|
    (1).upto(9) do |j|
      (1).upto(9) do |k|
        if (i * j * k) == n
          return [i, j, k]
        end
      end
    end
  end

  return nil
end

n = ! ARGV.empty? ? ARGV.first.to_i : 100

solution = solve(n)

if solution.nil?
  puts "No solution"
else
  puts solution.join('')
end
